package dao.impl.denglu;

import java.util.ArrayList;
import java.util.List;

import dao.BaseDao;
import dao.BizDao.denglu.Dl_BizDao;
import entity.denglu.Dl_ZhuCe;

public class Dl_BizDaoImpl extends BaseDao implements Dl_BizDao{

    public boolean getAll(Dl_ZhuCe dzc) {
		boolean flag=false;
		try {
			String sql="SELECT * FROM hy_zhuce WHERE USER=? AND password1=?";
			pst=getCon().prepareStatement(sql);
			pst.setString(1, dzc.getUser());
			pst.setString(2, dzc.getPwd());
			rs=pst.executeQuery();
			while(rs.next()){
				flag=true;
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}finally{
            close(cs, con, pst, rs);
		}
		
		return flag;
	}

 /*   public String getDl_ZhuCes(Dl_ZhuCe dzc) {
		String str="";
		try {
			String sql="SELECT userTypeName FROM hy_zhuce WHERE USER=? AND password1=?";
			pst=getCon().prepareStatement(sql);
			pst.setString(1, dzc.getUser());
			pst.setString(2, dzc.getPwd());
			rs=pst.executeQuery();
			while(rs.next()){
				str=rs.getString(1);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}finally{
            close(cs, con, pst, rs);
		}
		
		// TODO Auto-generated method stub
		return str;
	}

    public int getDl_ZhuCe(Dl_ZhuCe dzc) {
		int intt=0;
		try {
			String sql="SELECT userType FROM hy_zhuce WHERE USER=? AND password1=?";
			pst=getCon().prepareStatement(sql);
			pst.setString(1, dzc.getUser());
			pst.setString(2, dzc.getPwd());
			rs=pst.executeQuery();
			while(rs.next()){
				intt=rs.getInt(1);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}finally{
            close(cs, con, pst, rs);
		}

		// TODO Auto-generated method stub
		return intt;
	}
*/
	public List<Dl_ZhuCe> getXinXi(Dl_ZhuCe dzc) {
		// TODO Auto-generated method stub
		List<Dl_ZhuCe> listDl=new ArrayList<Dl_ZhuCe>();
		try {
			String sql="SELECT id,userType,userTypeName FROM hy_zhuce WHERE USER=? AND password1=?";
			pst=getCon().prepareStatement(sql);
			pst.setString(1, dzc.getUser());
			pst.setString(2, dzc.getPwd());
			rs=pst.executeQuery();
			while(rs.next()){
				Dl_ZhuCe ldzc=new Dl_ZhuCe();
				ldzc.setId(rs.getInt(1));
				ldzc.setQid(rs.getInt(2));
				ldzc.setPermission(rs.getString(3));
				listDl.add(ldzc);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}finally{
            close(cs, con, pst, rs);
		}
		
		return listDl;
	}

}
